package com.guoranhao.tool.model;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * Description: 触发器任务类
 * Copyright (c) Department of Research and Development/Beijing
 * All Rights Reserved.
 *
 * @version 1.0  2018/8/1 11:50  by 张振涛（zhangzt@cloud-young.com）创建
 */
public class TriggerTask implements Serializable {
    private static final long serialVersionUID = 5101568815753783712L;
    /**
     * 用户ID
     */
    private  Long userId;

    /**
     * 业务操作ID
     *
     */
    private Long businessId;
    /**
     * 业务操作编码
     */
    private String businessCode;
    /**
     * 设备型号
     */
    private String deviceModel;
    /**
     * 渠道id
     */
    private Long channelInfoId;
    /**
     *系统类型
     */
    private String platformNo;
    /**
     * 操作值（仅当规则操作值为随机情况下有效）
     */
    private Integer operateValue;

    /**
     * 是否启用业务传参 1：启用 0：不启用 (只有勋章计算时需要业务传参时使用)
     */
    private Integer enableParam=0;
    /**
     * 发送端给出的业务参数
     */
    private Map<String,Integer> params= new HashMap<>();

    public Long getBusinessId() {
        return businessId;
    }

    public void setBusinessId(Long businessId) {
        this.businessId = businessId;
    }

    public String getBusinessCode() {
        return businessCode;
    }

    public void setBusinessCode(String businessCode) {
        this.businessCode = businessCode;
    }

    public Long getUserId() {
        return userId;
    }

    public void setUserId(Long userId) {
        this.userId = userId;
    }


    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public String getDeviceModel() {
        return deviceModel;
    }

    public void setDeviceModel(String deviceModel) {
        this.deviceModel = deviceModel;
    }

    public Long getChannelInfoId() {
        return channelInfoId;
    }

    public void setChannelInfoId(Long channelInfoId) {
        this.channelInfoId = channelInfoId;
    }

    public String getPlatformNo() {
        return platformNo;
    }

    public void setPlatformNo(String platformNo) {
        this.platformNo = platformNo;
    }

    public Integer getOperateValue() {
        return operateValue;
    }

    public void setOperateValue(Integer operateValue) {
        this.operateValue = operateValue;
    }

    public Map<String, Integer> getParams() {
        return params;
    }

    public void setParams(Map<String, Integer> params) {
        this.params = params;
    }

    public Integer getEnableParam() {
        return enableParam;
    }

    public void setEnableParam(Integer enableParam) {
        this.enableParam = enableParam;
    }

    public static final class Builder {
        private TriggerTask triggerTask;

        private Builder() {
            triggerTask = new TriggerTask();
        }

        public static Builder newBuilder() {
            return new Builder();
        }

        public Builder userId(Long userId) {
            triggerTask.setUserId(userId);
            return this;
        }

        public Builder businessId(Long businessId) {
            triggerTask.setBusinessId(businessId);
            return this;
        }

        public Builder businessCode(String businessCode) {
            triggerTask.setBusinessCode(businessCode);
            return this;
        }

        public Builder deviceModel(String deviceModel) {
            triggerTask.setDeviceModel(deviceModel);
            return this;
        }

        public Builder channelInfoId(Long channelInfoId) {
            triggerTask.setChannelInfoId(channelInfoId);
            return this;
        }

        public Builder platformNo(String platformNo) {
            triggerTask.setPlatformNo(platformNo);
            return this;
        }

        public Builder operateValue(Integer operateValue) {
            triggerTask.setOperateValue(operateValue);
            return this;
        }
        public Builder params(Map<String,Integer> params) {
            triggerTask.setParams(params);
            return this;
        }
        public Builder enableParam(Integer enableParam) {
            triggerTask.setEnableParam(enableParam);
            return this;
        }
        public Builder but() {
            return newBuilder().userId(triggerTask.getUserId()).businessId(triggerTask.getBusinessId()).businessCode(triggerTask.getBusinessCode()).deviceModel(triggerTask.getDeviceModel()).channelInfoId(triggerTask.getChannelInfoId()).platformNo(triggerTask.getPlatformNo()).operateValue(triggerTask.getOperateValue()).params(triggerTask.getParams()).enableParam(triggerTask.getEnableParam());
        }

        public TriggerTask build() {
            return triggerTask;
        }
    }
}
